#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QXmlStreamReader>
#include <QFile>
#include <QTextStream>
#include <QVector>
#include <QHash>
#include <QMap>

#include "XmlParser.h"
#include "CsvParser.h"

namespace Ui
{
    class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

private:
    Ui::Dialog *ui;

    Q_SLOT void OnInputButtonClicked_();
    Q_SLOT void OnInputButton2Clicked_();
    Q_SLOT void OnGenerateButtonClicked_();
    Q_SLOT void OnCheckBoxStateChanged_(int State);

    void SetupConnections_();

    /**
     * @brief UpdateGenerateButton_
     *
     * Updates the state of the Generate button
     */
    void UpdateGenerateButton_();

    /**
     * @brief ReadXmlFile_
     *
     * Used to read and parse the XML file
     */
    void ReadXmlFile_();

    /**
     * @brief ReadXmlFile_
     *
     * Used to read and parse the input CSV file
     */
    void ReadCsvFile_();

    /**
     * @brief FindAttributesInPanelData_
     *
     * This function looks in the data from the XML file, in order to find
     * the attributes listed in the input CSV file.
     */
    void FindAttributesInPanelData_();

    /**
     * @brief CreateOutputDir_
     * @return true if success, false otherwise
     * @warning m_OutputDirPath is only valid if the function returns true
     */
    bool CreateOutputDir_();

    /**
     * @brief CreateOutputFile_
     * @param PanelIndex index of the panel being currently processed
     * @param rFile reference a file object
     * @return true if success, false otherwise
     * @warning rpOutputFile will only contain a valid file object upon
     * success
     */
    bool CreateOutputFile_(int PanelIndex, QFile& rFile);

    QString m_InputXmlFilePath;
    QString m_InputCsvFilePath;
    QString m_OutputDirPath;
    QString m_OutputFileNames;

    /**
     * @brief m_StoreFirstMatchOnly
     *
     * Determines whether we will store all the Dynamic GSOIDs matching
     * a given Static GSOID (if false), or only the first that matches (if true)
     */
    bool m_StoreFirstMatchOnly;

    XmlParser m_XmlParser;
    CsvParser m_CsvParser;
};

#endif // DIALOG_H
